package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.GestureDetectorCompat;

import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity  {
    private ImageButton btn1;
    private Button btn2;
    private GestureDetectorCompat detectorCompat;


    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btn1 = findViewById(R.id.button2);
        btn2 = findViewById(R.id.button3);
        btn2.setOnClickListener(view -> {
            Toast.makeText(this,"按钮点击",Toast.LENGTH_SHORT).show();
        });
        detectorCompat = new GestureDetectorCompat(this, new xindelei());

    }


    public boolean onTouchEvent(MotionEvent event) {
        detectorCompat.onTouchEvent(event);
        return super.onTouchEvent(event);
    }

    public void btn1clk(View view) {
        Toast.makeText(this, "按钮点击", Toast.LENGTH_SHORT).show();
    }

    public void btn2clk(View view) {
        Toast.makeText(this, "按钮点击", Toast.LENGTH_SHORT).show();
    }


    public void btn3Clk(View view) {
        Toast.makeText(this, "浮动按钮点击", Toast.LENGTH_SHORT).show();
    }
}